//
//  ZXWeakProxy.m
//  ZXTimer
//
//  Created by 朱新明 on 2023/6/12.
//

#import "ZXWeakProxy.h"
#import <objc/runtime.h>

@implementation ZXWeakProxy

- (void)dealloc{
    
}

- (instancetype)initWithTarget:(id)target{
    _target = target;
    return self;
}

+ (instancetype)proxyWithTarget:(id)target {
    return [[ZXWeakProxy alloc] initWithTarget:target];
}


- (void)forwardInvocation:(NSInvocation *)invocation{
    [invocation invokeWithTarget:self.target];
}
- (nullable NSMethodSignature *)methodSignatureForSelector:(SEL)sel{
    return [self.target methodSignatureForSelector:sel];
}


- (BOOL)isEqual:(id)object{
    return [self.target isEqual:object];
}

- (NSUInteger)hash{
    return [self.target hash];
}

- (Class)superclass{
    return [self.target superclass];
}

- (Class)class{
    return [self.target class];
}


- (BOOL)isKindOfClass:(Class)aClass{
    return [self.target isKindOfClass:aClass];
}

// (2)判断是否是某个类的实例;
- (BOOL)isMemberOfClass:(Class)aClass{
    return [self.target isMemberOfClass:aClass];
}

- (BOOL)conformsToProtocol:(Protocol *)aProtocol{
    return [self.target conformsToProtocol:aProtocol];
}

- (BOOL)respondsToSelector:(SEL)aSelector{
    return [self.target respondsToSelector:aSelector];
}

- (BOOL)isProxy{
    return YES;
}

@end
